feat(calculator): add "Copy for AI assistant" export button (#553)#569
Merged
Conversation
Adds a "Copy for AI" section to the calculator report (above More Reading) with a button that opens a preview modal of the full benefit-derivation markdown and copies it to the clipboard, for pasting into an AI assistant. Works for both single recipients and couples. Builds on the #553 ai-export builder merged in #568. - copy-for-ai.ts: localIsoDate (local YYYY-MM-DD, no UTC off-by-one) and a single/couple dispatch helper over the ai-export builders (unit tested). - CopyForAiButton.svelte: trigger button styled as the report's primary CTA, opening a native <dialog> preview with clipboard copy, a PII disclosure, and a posthog event. Built lazily on open for determinism. - Wired into the calculator report; Storybook story for Chromatic coverage. All data stays client-side; the markdown is only built on demand and never leaves the device until the user pastes it.
Deploying social-security-tools with
|
| Latest commit: |
6c03f7f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://50720b4d.social-security-tools.pages.dev |
| Branch Preview URL: | https://worktree-feat-553-copy-for-a.social-security-tools.pages.dev |
- Clear the "Copied!" reset timer on component destroy (onDestroy), matching the timer-cleanup convention in Sidebar / MobileDesktopPrompt, so the callback can't assign state on a torn-down component. - Add a regression test pinning the production default baseUrl through the no-options dispatch path (the live button's actual call shape). - Clarify the determinism comment (the property comes from the delegate builder + module-load constants), narrow the timezone test comment, and document why the button is hidden in print.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Copy for AI section to the calculator report (just above More Reading) with a button that opens a preview modal of the full benefit-derivation markdown and copies it to the clipboard — for pasting into ChatGPT, Claude, or another AI assistant. Works for both single recipients and couples.
This is the Phase 2 UI for #553; it builds on the
ai-exportbuilder merged in #568.What's included
copy-for-ai.ts(importable, unit-tested):localIsoDate()— formats the "Generated" date from local calendar parts (avoids thetoISOString()UTC off-by-one the builder docs warn about).buildCalculatorExport(recipient, spouse | null, options)— dispatches to the single vs couple builder.CopyForAiButton.svelte— trigger button styled as the report's primary CTA (matchesStrategyPromo), opening a native<dialog>preview with: scrollable markdown, "Copy to clipboard" (→ "Copied!"), a PII disclosure, a copy-failure fallback, and a posthog event. The export is built lazily on open for determinism.+page.svelte) as its own section + sidebar-nav entry.Privacy
All data stays client-side. The markdown is only built on demand and never leaves the device until the user pastes it; the modal warns about the birthdate/earnings/PIA it contains.
Testing
copy-for-ai.test.ts): date formatting/locality, single-vs-couple dispatch,generatedDate/baseUrlpassthrough, determinism.npm run qualityclean (Biome + svelte-check 0/0).Follow-ups (not in this PR)
/strategyreport.npm run devworks with the COEP header (currently the dev runtime fails to load dynamic modules underrequire-corp).